<script>
	document.addEventListener("visibilitychange", function () {
		console.log("document.visibilityState=>   ", document.visibilityState);
		// 页面变为不可见时触发
		if (document.visibilityState == "hidden") {
			sessionStorage.setItem("leaveTime", new Date().getTime());
		}
		// 页面变为可见时触发
		if (document.visibilityState == "visible") {
			const leaveTime = Number(sessionStorage.getItem("leaveTime"));
			if (new Date().getTime() - leaveTime > 5 * 60 * 1000) {
				// 清空登录信息
				document.cookie = "session=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
				// 超过五分钟返回登录页
				window.location.href = "/login";
			}
		}
	});
</script>
